Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Passing numeric data containing < or > django to javascript

am having a problem with char inside numeric data, it's too large to be cleaned. anyways. I want to replace < and > from value. just posting relevant codes. views.py

def search_result(request):
    if request.method == "POST":
        ChemSearched = request.POST.get('ChemSearched')
        tarname = BINDLL.objects.filter(targetnameassignedbycuratorordatasource__contains=ChemSearched).exclude(ki_nm__isnull=True)[:120]
        
        return render(request, 'Search/search_result.html',{'ChemSearched':ChemSearched,'tarname':tarname})

Html side

<script>
     data=[{% for Bindll in tarname %} {
                group: '{{ Bindll.targetnameassignedbycuratorordatasource }}',
                     variable:'{{ Bindll.zincidofligand}}',
                     value: {{Bindll.ki_nm|safe}}
                    }, {% endfor %}];

which is used by graph d3.js. all go well unless I have '<' or '>' in value I'll have this result

Uncaught SyntaxError: Unexpected token '>' or if use escape value: {{Bindll.ki_nm|escape}} Uncaught SyntaxError: Unexpected token '&lt' any function to be used in Html side javascript to replace char or anything and keep only numeric like regex replace. thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!